<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>教师认证</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui2/aui.css" />
	<style>
	    .button.green {
            background-color: #009688;
        }
        .button.green:active{
            background-color: #0068B0;
        }
        .button {
            display: block;
            color: white;
            margin: 0px 0px;
            text-align: center;
            border-radius: 3px;
            height: 40px;
            line-height: 40px;
        }
	    .red{
        	border:1px solid red !important;
        }
        .aui-radio:checked, .aui-radio.aui-checked, .aui-checkbox:checked, .aui-checkbox.aui-checked {
		    background-color: #009688;
		    border: solid 0px;
	    }
	</style>
</head>
<body>
	<header class="aui-bar aui-bar-nav">
        <div class="aui-pull-left aui-btn" id="btn_return" onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>返回
        </div>
        <div class="aui-title">教师认证</div>
    </header>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label ">
                        导师姓名
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="导师姓名" id="sales_name" class="txt">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        导师手机号
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="导师手机号" id="sales_phone" class="txt">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        职称
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="职称" id="title" class="txt">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        教师简介
                    </div>
                    <div class="aui-list-item-input">
                        <textarea placeholder="教师简介" id="description" class="txt"></textarea>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        是否发短信
                    </div>
                    <div class="aui-list-item-input">
                        <label><input class="aui-radio" type="radio" name="needSendSMS" value=1 checked> 发短信</label>
                        <label><input class="aui-radio" type="radio" name="needSendSMS" value=0> 不发短信</label>
                    </div>
                </div>
            </li>
        </ul>
    </div>
     <div class="button green" tapmode="" onclick="authTeacher()">
       	 认证
    </div>
</body>
<script data-main="../../script/main" src="../../script/require.js"></script>
<script type="text/javascript">
	apiready = function(){
		require(["zepto","api","common"],function(){
			var header = $api.dom('header');
			$api.fixStatusBar(header);
			var headerPos = $api.offset(header);
			
			$(".txt").on("focus",function(){
	        	$(this).removeClass("red");	
	    	});
		})
	};
	function authTeacher(){
		var retmsg = check();
    	if(retmsg){
    		api.toast({
                msg:retmsg
            });
    		return;
    	}
    	$zb.prefs.getPrefs('token',function(result) {
	        if(result.value) {
	        	var data={
		    		values:{
		    			token : result.value,
		        		sales_name : $("#sales_name").val(),
		        		sales_phone : $("#sales_phone").val(),
		        		title : $("#title").val(),
		        		description : $("#description").val(),
		        		needSendSMS : $('input[name="needSendSMS"]:checked').val()
		        	}
		    	}
    			$zb.requestForData(data,'user','submitAuthTeacher',function(ret){
    				if (ret.status == 'OK') {
		            	api.toast({ msg: '申请认证成功' });
						api.closeWin();
		            }else {
		                api.toast({ msg: ret.status });
		            }
    			});
			}
		})
	}
	function check(){
		var ret_message=null;
    	if(!$("#sales_name").val()){
    		ret_message = "请输入导师姓名";
    		$("#sales_name").addClass("red");
    		return ret_message;
    	}
    	if(!$("#sales_phone").val()){
    		ret_message = "请输入导师手机号";
    		$("#sales_phone").addClass("red");
    		return ret_message;
    	}
    	if(!$("#title").val()){
    		ret_message = "请输入职称";
    		$("#title").addClass("red");
    		return ret_message;
    	}
    	if(!$("#description").val()){
    		ret_message = "请输入教师简介";
    		$("#description").addClass("red");
    		return ret_message;
    	}
	}
</script>
</html>